package arlpanda.lcmtypes;
 
import java.io.*;
import java.util.*;
 
public final class motor_feedback_t implements lcm.lcm.LCMEncodable
{
    public long utime;
    public boolean estop;
    public short nmotors;
    public int encoders[];
    public float current[];
    public float applied_voltage[];
 
    public motor_feedback_t()
    {
    }
 
    public static final long LCM_FINGERPRINT;
    public static final long LCM_FINGERPRINT_BASE = 0x1a793f72a7a09d71L;
 
    static {
        LCM_FINGERPRINT = _hashRecursive(new ArrayList<Class>());
    }
 
    public static long _hashRecursive(ArrayList<Class> classes)
    {
        if (classes.contains(arlpanda.lcmtypes.motor_feedback_t.class))
            return 0L;
 
        classes.add(arlpanda.lcmtypes.motor_feedback_t.class);
        long hash = LCM_FINGERPRINT_BASE
            ;
        classes.remove(classes.size() - 1);
        return (hash<<1) + ((hash>>63)&1);
    }
 
    public void encode(DataOutput outs) throws IOException
    {
        outs.writeLong(LCM_FINGERPRINT);
        _encodeRecursive(outs);
    }
 
    public void _encodeRecursive(DataOutput outs) throws IOException
    {
        byte[] __strbuf = null;
        outs.writeLong(this.utime); 
 
        outs.writeByte( this.estop ? 1 : 0); 
 
        outs.writeShort(this.nmotors); 
 
        for (int a = 0; a < nmotors; a++) {
            outs.writeInt(this.encoders[a]); 
        }
 
        for (int a = 0; a < nmotors; a++) {
            outs.writeFloat(this.current[a]); 
        }
 
        for (int a = 0; a < nmotors; a++) {
            outs.writeFloat(this.applied_voltage[a]); 
        }
 
    }
 
    public motor_feedback_t(byte[] data) throws IOException
    {
        this(new DataInputStream(new ByteArrayInputStream(data)));
    }
 
    public motor_feedback_t(DataInput ins) throws IOException
    {
        if (ins.readLong() != LCM_FINGERPRINT)
            throw new IOException("LCM Decode error: bad fingerprint");
 
        _decodeRecursive(ins);
    }
 
    public static arlpanda.lcmtypes.motor_feedback_t _decodeRecursiveFactory(DataInput ins) throws IOException
    {
        arlpanda.lcmtypes.motor_feedback_t o = new arlpanda.lcmtypes.motor_feedback_t();
        o._decodeRecursive(ins);
        return o;
    }
 
    public void _decodeRecursive(DataInput ins) throws IOException
    {
        byte[] __strbuf = null;
        this.utime = ins.readLong();
 
        this.estop = ins.readByte()!=0;
 
        this.nmotors = ins.readShort();
 
        this.encoders = new int[(int) nmotors];
        for (int a = 0; a < nmotors; a++) {
            this.encoders[a] = ins.readInt();
        }
 
        this.current = new float[(int) nmotors];
        for (int a = 0; a < nmotors; a++) {
            this.current[a] = ins.readFloat();
        }
 
        this.applied_voltage = new float[(int) nmotors];
        for (int a = 0; a < nmotors; a++) {
            this.applied_voltage[a] = ins.readFloat();
        }
 
    }
 
    public arlpanda.lcmtypes.motor_feedback_t copy()
    {
        arlpanda.lcmtypes.motor_feedback_t outobj = new arlpanda.lcmtypes.motor_feedback_t();
        outobj.utime = this.utime;
 
        outobj.estop = this.estop;
 
        outobj.nmotors = this.nmotors;
 
        outobj.encoders = new int[(int) nmotors];
        for (int a = 0; a < nmotors; a++) {
            outobj.encoders[a] = this.encoders[a];
        }
 
        outobj.current = new float[(int) nmotors];
        for (int a = 0; a < nmotors; a++) {
            outobj.current[a] = this.current[a];
        }
 
        outobj.applied_voltage = new float[(int) nmotors];
        for (int a = 0; a < nmotors; a++) {
            outobj.applied_voltage[a] = this.applied_voltage[a];
        }
 
        return outobj;
    }
 
}

